package com.dawn.interestmanage.action;

import java.util.Map;
import java.util.List;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.dawn.interestmanage.bean.InterestinfoBean;
import com.opensymphony.xwork2.ActionSupport;
import com.dawn.interestmanage.service.InterestinfoService;

@Controller("InterestAction")
@Scope("prototype") 
public class InterestAction extends ActionSupport implements SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

    public Map<String, Object> getSession() {
		return session;
	}

	private Map<String, Object> session;
	private InterestinfoBean interestBean;
	public List<InterestinfoBean> getInterests() {
		return interests;
	}

	public void setInterests(List<InterestinfoBean> interests) {
		this.interests = interests;
	}

	private List<InterestinfoBean> interests;
    @Autowired
	private InterestinfoService IntereService;
	
	
	public InterestinfoBean getInterestBean() {
		return interestBean;
	}

	public void setInterestBean(InterestinfoBean interestBean) {
		this.interestBean = interestBean;
	}

	 
	public String showInterest() {
		interests = IntereService.findAllInter();
		interestBean=interests.get(0);
        if(null == interests)
	            return ERROR;
	        return SUCCESS;      
    }

	public String addInterest() {
		    //interestBean.setInterestId(3);
	 
		    //interestBean.setInterestName("123");
		    IntereService.AddInterest(interestBean);
	        return SUCCESS;      
	 
	 
		 
    }
	@Override
	public void setSession(Map<String, Object> session) {
		// TODO Auto-generated method stub
		  this.session = session;
	}

}
